<!--
 * @Author: 杨超
 * @Date: 2021-11-24 20:33:45
 * @LastEditTime: 2021-12-01 17:33:30
 * @LastEditors: 杨超
 * @Description:
-->
<template>
    <!-- 普通输入框 -->
    <div :style="item.style || {}" :class="`form-unqiue-${item.key}`">
        <el-input
            v-if="!getTextModel"
            v-model="val"
            :class="{ 'placeholder-error-tip': error }"
            :placeholder="error || getPlaceholder(item)"
            :disabled="getDisabled"
            type="textarea"
            :autosize="item.autosize || false"
            :rows="item.rows || 4"
            :resize="item.resize || 'none'"
            v-bind="item"
            @blur="e => onBlur(item, e)"
            @focus="e => onFocus(item, e)"
        />
        <div v-else :style="item.textStyle || {}" class="">
            <!-- {{ val || '-' }} -->
            <!-- 防止字数过多显示换行错位，这里还是用textarea回显，移除了上面的类form-input-text -->
            <el-input v-model="val" type="textarea" readonly :rows="item.autosize ? '' : 3" :resize="item.resize || 'none'"></el-input>
        </div>
    </div>
</template>

<script>
import FormMixin from './mixin'

export default {
    name: 'FormInput',
    mixins: [FormMixin],
    data() {
        return {}
    },
    computed: {
        // 前置符号
        prepend() {
            // 兼容性处理
            if (this.item.prepend) {
                return this.item.prepend
            } else if (this.item.prependMsg) {
                return this.item.prependMsg
            } else {
                return ''
            }
        },
        // 后置符号
        append() {
            // 兼容性处理
            if (this.item.append) {
                return this.item.append
            } else if (this.item.appendMsg) {
                return this.item.appendMsg
            } else {
                return ''
            }
        }
    }
}
</script>

<style scoped lang="scss"></style>
